#ifndef YTESTSMALLSYNTAX_H
#define YTESTSMALLSYNTAX_H
#include <iostream>
using namespace std;

//////////////////////////explicit/////////////////////////
class mycomplex{
    friend ostream& operator<<(ostream&out,const mycomplex &obj);
    public:
    mycomplex()=default;
    mycomplex(double real, double img =0.0):mreal(real),mimg(img)
    {
        cout<<"this constructor="<<this<<"\t"<<endl;
    }
    mycomplex operator+(const mycomplex &obj)
    {
        cout<<"this operator+="<<this<<"\t"<<endl;
        return mycomplex(this->mreal+obj.mreal,this->mimg+obj.mimg);
    }
    mycomplex(const mycomplex &obj)
    {
        cout<<"this copy constructor="<<this<<"\t"<<endl;
        mreal = obj.mreal;
        mimg = obj.mimg;
    }
    ~mycomplex()
    {
       cout<<"this delete constructor="<<this<<"\t"<<endl; 
    }
 private:
    double mreal = 1.0,mimg={0.0};

};
ostream& operator<<(ostream &out, const mycomplex &obj)
{
    out<<"("<<obj.mreal<<","<<obj.mimg<<")"<<endl;
}
///////////////////////////////////override///////////////////////////////////
//override表示重写了与基类完全一样的虚函数,如果不一样则报错
//1.与基类完全一样的签名
//2.虚函数重写只能用于虚函数
struct Base{
    virtual void func(float a);
};

struct Derived1:public Base{
    void func(float a) override;
    // virtual void func(int a) override;//形参类型不一样
    // virtual void func1(int a) override;//基类没有func1的虚函数
    // virtual int func(float a) override;//返回类型不一样
};
struct Derived2:public Base{
    virtual void func(float b) override;
};
///////////////////////////////////final///////////////////////////////////
//final
//1.用于类后面表示此类不能被继承
//2.只能用于虚函数表示不能被重写
struct FA {
    virtual void func(float a);
    void func1(int a);
};

struct FB :public FA{
    virtual void func(float a);
    // virtual void func(int a) override;//形参类型不一样
    // virtual void func1(int a) override;//基类没有func1的虚函数
    // virtual int func(float a) override;//返回类型不一样
};
struct FC:public FB{
    virtual void func(float b) override;
};
////////////////////////////decltype//////////////////////
#include <map>
#include <string>
template <typename T1, typename T2>
auto add(T1 x, T2 y)->decltype(x+y)
{
    std::map<std::string,int> col;
    std::map<string,int>::value_type v1;

    decltype(col)::value_type v2;

    return x+y;
}
void testSmallSyntax()
{

    cout<<__cplusplus<<endl;
    cout<<"//////////////////////1//////////////////////////"<<endl;
    mycomplex c1(2.5,3.0);//0xb0
    cout<<"//////////////////////2//////////////////////////"<<endl;
    //5.0 0x70
    //c1 0xb0
    //tmp 0x18
    //c2 90
    mycomplex c2 = c1 +5.0; 
    cout<<"//////////////////////3//////////////////////////"<<endl;

    mycomplex c3;
    cout<<"//////////////////////4//////////////////////////"<<endl;



}


#endif